package sprint1;

import java.util.ArrayList;

/**
 * @author Marco Schultewolter
 * @author Yoeri Goldewijk 
 * Afgemaakt @ 10-12-2009
 */

public class Inventory {
	private int size;
	private ArrayList<Item> items;

	public Inventory(int size) {
		this.size = size;
		items = new ArrayList<Item>();
	}

	public boolean addItem(Item item) {
		if (items.size() < size) {
			items.add(item);
			return true;
		} else {
			return false;
		}
	}

	public void setSize(int newSize) {
		size = newSize;
	}

	public int getSize() {
		return size;
	}

	public void printInventory() {
		for (Item i : items) {
			System.out.println(i);
		}
	}

	public void printInventory(boolean showIndex) {
		if (!showIndex) {
			printInventory();
			return;
		}

		for (int i = 0; i < items.size(); i++) {
			System.out.println(i + ": " + items.get(i));
		}
	}

	public ArrayList<Item> getInventory() {
		return items;
	}

	public void useItem(int index) {
		items.get(index).useItem();
	}

	public String removeItem(int index) {
		return items.remove(index).getName();
	}

}
